<template>
  <div>
<!--    text-align: center;-->
    <h2 style="color: #34373b;padding-top: 50px;padding-left: 350px">意见与反馈</h2>
    <div class="zz">
      <p style="padding-left: 50px;padding-right: 50px;text-indent:2em">&emsp;&emsp;&emsp; &emsp;&nbsp; 用户您好，请将您的意见、想法、建议或投诉内容告诉我们，以帮助为全体用户提供更加优质的服务。我们将在两个工作日之内回复您的反馈。</p>
      <el-input
              type="textarea"
              placeholder="请输入内容"
              v-model="feedbackContent"
              show-word-limit
              :rows="10"
              style="padding-left: 50px;padding-right: 50px;"
      >
      </el-input>
      <el-button 
        type="info" 
        plain 
        style="margin-left: 750px"
        @click="handleSubmit"
      >提交</el-button>
    </div>
  </div>
</template>

<script>
import store from '@/store'

export default {
  data() {
    return {
      feedbackContent: ''
    }
  },
  methods: {
    handleSubmit() {
      console.log('点击提交按钮');
      
      if (!this.feedbackContent.trim()) {
        this.$message.warning('请输入反馈内容');
        return;
      }

      // 先获取用户信息
      this.$axios.post("/jobSeeker/getOne", {}).then(res => {
        if (res.code === 200 && res.data) {
          const jobSeekerId = res.data.id;
          console.log('求职者ID:', jobSeekerId);

          // 发送反馈
          this.$axios({
            method: 'post',
            url: '/unlike/add',
            data: {
              jobSeekerId: jobSeekerId,  // 使用 jobSeekerId
              content: this.feedbackContent.trim()
            },
            headers: {
              'Content-Type': 'application/json',
              'Authorization': sessionStorage.getItem('JWT_TOKEN')
            }
          }).then(res => {
            console.log('提交响应:', res);
            if (res.code === 200) {
              this.$message.success('提交成功');
              this.feedbackContent = '';
            } else {
              this.$message.error(res.msg || '提交失败');
            }
          }).catch(err => {
            console.error('提交失败:', err);
            this.$message.error('提交失败');
          });
        } else {
          this.$message.error('获取用户信息失败');
        }
      }).catch(err => {
        console.error('获取用户信息失败:', err);
        this.$message.error('获取用户信息失败');
      });
    }
  },

  mounted() {

  },
  watch: {

  }
}
</script>

<style>
  .hr {
    margin: 20px auto auto auto;
  }
  .zz{
    font-size: 20px;
    line-height: 30px;
    margin-left: 350px;
    margin-right: 500px;
    height: 650px;
    width: 1000px;
    border: 1px solid #f5f5f5;
    padding: 40px 60px;
    background-image:url("../../static/images/i2.jpg");
  }
</style>
